package ar.fiuba.tp7552.buildadmin.dao.impl;

import java.util.Collection;

import org.hibernate.Criteria;
import org.hibernate.Session;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;

import ar.fiuba.tp7552.buildadmin.dao.GenericDaoHibernate;
import ar.fiuba.tp7552.buildadmin.dao.ResponsableDao;
import ar.fiuba.tp7552.buildadmin.model.builds.Responsable;
import ar.fiuba.tp7552.buildadmin.util.Cast;

public class ResponsableDaoImpl extends GenericDaoHibernate<Responsable, Long> implements ResponsableDao {

	public ResponsableDaoImpl() {
		super(Responsable.class);
	}

	@Override
	public Collection<Responsable> find(String name) {
		Session session = this.getHibernateSession();
		Criteria crit = session.createCriteria(Responsable.class)
			.add(Restrictions.ilike("nombre", name, MatchMode.ANYWHERE));
		return Cast.collection(Responsable.class, crit.list());
	}
	
}
